package cn.edu.glut.dto;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class TextResponse {
	private int error;
	private String url;
	private String message;
	private static final int SUCCESS_CODE = 0;
	private static final int FAILURE_CODE = 1;
	private static final String DEFAULT_FAILUE_MESSAGE = "上传失败";
	
	public TextResponse(int error, String url) {
		super();
		this.error = error;
		this.url = url;
	}

	public TextResponse(String message,int error) {
		super();
		this.error = error;
		this.message = message;
	}
	
	public static TextResponse success(String url){
		return new TextResponse(SUCCESS_CODE,url);
	}
	
	public static TextResponse failure(String message){
		return new TextResponse(message, FAILURE_CODE);
	}
	
	public static TextResponse failure(){
		return new TextResponse(DEFAULT_FAILUE_MESSAGE, FAILURE_CODE);
	}
}
